﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ServiceModel;
using MobileSales.Website.Properties;
using System.ServiceModel.Channels;

namespace MobileSales.Website.Infrastructure
{
    /// <summary>
    /// WCF Services extension methods
    /// </summary>
    public static class ClientBaseExtensions
    {
        #region AddValidationToken

        public static void AddValidationToken<TChannel>(this ClientBase<TChannel> client, string token) where TChannel : class
        {
            OperationContextScope scope = new OperationContextScope(client.InnerChannel);
            MessageHeader<string> mhg = new MessageHeader<string>(token);
            MessageHeader untyped = mhg.GetUntypedHeader(Settings.Default.TokenKey, string.Empty);
            OperationContext.Current.OutgoingMessageHeaders.Add(untyped);
        }

        #endregion

    }
}
